//
//  DSZGuanYuViewController.m
//  7.13苏宁框架
//
//  Created by app05 on 15/7/23.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "DSZGuanYuViewController.h"
#import "DSZNavigationBarView.h"
#import "DSZMoreView.h"
#import "DSZSHDZVeiw.h"
#import "DSZStyleOneCell.h"
#import "DSZGuanYuHeaderView.h"
#import "DSZMainViewController.h"
#import "HomeViewController.h"
#import "DSZShopViewController.h"
#import "UMSocial.h"
@interface DSZGuanYuViewController ()<UITableViewDataSource,UITableViewDelegate,navigationBarDelegata,tableViewIndexPathRowDelegate>

@property(nonatomic,weak)UIView *moreView;
@property(nonatomic,assign)BOOL flag;

@end

@implementation DSZGuanYuViewController

-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.alpha=0;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIView *view=[[UIView alloc]initWithFrame:self.view.bounds];
    view.backgroundColor=[UIColor whiteColor];
    self.view=view;
    
    [self addNavBar];
    
    [self addContentView];
}
-(void)addNavBar
{
    DSZNavigationBarView *nav=[[DSZNavigationBarView alloc]initWithFrame:CGRectZero];
    nav.frame=CGRectMake(0, 20, 320, 44);
    [self.view addSubview:nav];
    nav.delegate=self;
    nav.titleLabel=@"关于";
}
-(void)addContentView
{
        UITableView *tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 64, 320, 370) ];
        tableView.backgroundColor=[UIColor clearColor];
        [self.view addSubview:tableView];
        tableView.delegate=self;
        tableView.dataSource=self;
        tableView.scrollEnabled=NO;
   
        tableView.tableHeaderView=[DSZGuanYuHeaderView guanYuHeaderView];
    
}
-(void)btnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)moreBtnClick
{
    
    if (!self.flag) {
        DSZMoreView *more=[DSZMoreView moreView];
        more.delegate=self;
        more.frame=CGRectMake(185, 65, 146, 229);
        self.moreView=more;
        [self.view addSubview:self.moreView];
        self.flag=YES;
    }
    else
    {
        [self.moreView removeFromSuperview];
        self.moreView=nil;
        self.flag=NO;
    }
}
-(NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell=nil;
    
    if (indexPath.section==0&&indexPath.row==0) {
        DSZStyleOneCell *cell1=[DSZStyleOneCell guanguanyu];
        cell=cell1;
    }else
    {
        DSZStyleOneCell *cell1=[DSZStyleOneCell guanguanyu1];
        cell=cell1;
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0) {
        [self share];
    }
    else
    {
        UIApplication *app = [UIApplication sharedApplication];
        NSString *urlStr = @"http://s.suning.com/report.htm";
        NSURL *url = [NSURL URLWithString:urlStr];
        if ([app canOpenURL:url]) {
            [app openURL:url];
        }
        
    }
}
-(void)dszMoreViewWithIndexRow:(NSInteger)indexPathRow
{
    if (indexPathRow==0) {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        DSZMainViewController *main=[story instantiateViewControllerWithIdentifier:@"main"];
        //DSZMainViewController *main=[[DSZMainViewController alloc]init];
        [self presentViewController: main animated:NO completion:nil];
    }else if (indexPathRow==1)
    {}
    else if (indexPathRow==2)
    {
        UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        
        DSZShopViewController *shop=[story instantiateViewControllerWithIdentifier:@"shop"];
        [self.navigationController pushViewController:shop animated:NO];
        self.flag=YES;
        [self moreBtnClick];
        self.navigationController.navigationBar.alpha=1;
        DSZMainViewController *main=(DSZMainViewController*)self.tabBarController;
        [main hiddenMainTabbar:YES];
    }else if (indexPathRow==3)
    {
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    }
    
}
-(void)share{
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"559f929067e58e3ddf00500d"
                                      shareText:@"苏宁家族，乐你分享！"
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:@[UMShareToSina,UMShareToTencent,UMShareToDouban,UMShareToQzone,UMShareToEmail]
                                       delegate:nil];
}

@end